<!DOCTYPE html>
<html lang="cn-zh">

<head>
  
  <meta charset="utf-8">



<meta name="viewport" content="width=device-width, initial-scale=1.0">


  
    <meta name="description" content=" 问题描述 开发过程中出现ScrollView滑动会会使NavigationBar出现白边问题
正常情况 异常情况 解决方法 在iOS13版本之后添加以下代码可以解决该问题，代码放到第一个UIControllerView的viewDidLoad方法中
if #available(iOS 13.0, *) { let apperance = UINavigationBarAppearance() apperance.backgroundColor = UIColor.black self.navigationController?.navigationBar.standardAppearance = apperance } ">
  


<meta name="color-scheme" content="light dark">







<meta name="generator" content="Hugo 0.111.2">

<meta content="" name="keywords">
<meta content="解决UINavigationController 滑动UIScrollView出现白边问题 - 通通不同-博客" property="og:title">
<meta content="开发的乐趣在于相通而不同 - " property="og:description">

<meta name="msvalidate.01" content="F56ED94B7E86941E3DACEF208F07D329" />

  <title>
    
    解决UINavigationController 滑动UIScrollView出现白边问题
     - 通通不同-博客
    
</title>

  <link rel="canonical" href="https://codebeautiful.gitee.io/post/uinavigationcontroller_scrollview_whiten/">


  








  
    
  
  
  <link rel="stylesheet" href="/css/base.min.4f231885947d13c748c815d93da49f07ab89afb67629f9970b7c054610e88e0b.css" integrity="sha256-TyMYhZR9E8dIyBXZPaSfB6uJr7Z2KfmXC3wFRhDojgs=" crossorigin="anonymous">



</head>

<body>
  <nav class="u-background">
  <div class="u-wrapper">
    <ul class="Banner">
      <li class="Banner-item Banner-item--title">
        <h1 class="Banner-heading">
          <a class="Banner-link u-clickable" href="/">通通不同-博客</a>
        </h1>
      </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/post/">全部</a>
        </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/categories/">分类</a>
        </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/tags/">标签</a>
        </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/about/">关于</a>
        </li>
      
    </ul>
  </div>
</nav>

  <main>
    <div class="u-wrapper">
      <div class="u-padding">
        

  <article>
    <header class="Heading">
  <h2 class="Heading-title">
    <a class="Heading-link u-clickable" href="/post/uinavigationcontroller_scrollview_whiten/" rel="bookmark">解决UINavigationController 滑动UIScrollView出现白边问题</a>
  </h2>
  
    <time datetime="2023-03-31T15:18:50&#43;08:00">31 March, 2023</time>
  
</header>

    <h3 id="问题描述">
  <a class="Heading-link u-clickable" href="/post/uinavigationcontroller_scrollview_whiten/#%e9%97%ae%e9%a2%98%e6%8f%8f%e8%bf%b0">问题描述</a>
</h3>
<blockquote>
<p>开发过程中出现ScrollView滑动会会使NavigationBar出现白边问题</p>
</blockquote>
<ul>
<li>正常情况
<img src="/images/UINavigationWhiten1.png" alt="正常情况"></li>
<li>异常情况
<img src="/images/UINavigationWhiten2.png" alt="正常情况"></li>
</ul>
<h3 id="解决方法">
  <a class="Heading-link u-clickable" href="/post/uinavigationcontroller_scrollview_whiten/#%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95">解决方法</a>
</h3>
<blockquote>
<p>在iOS13版本之后添加以下代码可以解决该问题，代码放到第一个UIControllerView的viewDidLoad方法中</p>
</blockquote>

<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-swift" data-lang="swift"><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#75715e">#available</span>(<span style="color:#75715e">iOS</span> <span style="color:#ae81ff">13.0</span>, <span style="color:#f92672">*</span>) {
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">let</span> apperance = UINavigationBarAppearance()
</span></span><span style="display:flex;"><span>  apperance.backgroundColor = UIColor.black
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">self</span>.navigationController?.navigationBar.standardAppearance = apperance
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>}</span></span></code></pre></div>

    


  

  

  





    
  

  </article>


      </div>
    </div>
  </main>
  
  <footer class="Footer">
    <div class="u-wrapper">
      <div class="u-padding">
        开发的乐趣在于相通而不同
      </div>
    </div>
  </footer>


  <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?d08a2ad355cb7a065a41be081b43297e";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>

</body>

</html>
